package com.ldwx.center.controller;

import com.ldwx.center.common.entity.Result;
import com.ldwx.center.common.entity.StatusCode;
import com.ldwx.center.model.Recruit;
import com.ldwx.center.service.RecruitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/recruit")
public class RecruitController {

    @Autowired
    private RecruitService service;

    /**
     * 查询所有招聘任务
     * @return
     */
    @RequestMapping(method = RequestMethod.GET)
    public Result findAll() {
        List<Recruit> list = service.findAll();
        return new Result(true, StatusCode.OK, "查询成功", list);
    }

    /**
     * 发布招聘
     * @param recruit
     * @return
     */
    @RequestMapping(method = RequestMethod.POST)
    public Result save(Recruit recruit) {
        service.save(recruit);
        return new Result(true, StatusCode.OK, "发布成功");
    }
}
